public class demo2 {
//  Thread(String name)线程中的构造方法 给线程取名
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while (true) {
                System.out.println("hello");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "thread1");//取名

        Thread t2 = new Thread(() -> {
            while (true) {
                System.out.println("world");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "thread2");

        t1.start();
        t2.start();

//        可以在jdk-bin-jconsole.exe我就中查看线程
    }
}
